﻿// ***********************************************************************************************
// <summary author="holly.dai" create_date="2009/9/8" modify_date="">
//         KM文档移植文档添加的EventHandler类
// </summary> 
// <modify_log>
//
// </modify_log>
// <copyright file="KMDocumentTransferEventHandler.cs" company="DEXTRYS" url="http://www.dextrys.com">
//           新宇软件（苏州工业园区）有限公司
// </copyright>
// ***********************************************************************************************
namespace Higer.SharePoint.EventHandler
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Dextrys.SharePoint;
    using Microsoft.SharePoint;

    /// <summary>
    /// KM文档移植文档属性添加事情
    /// </summary>
    public class KMDocumentTransferEventHandler : BaseItemEventReceiver
    {
        /// <summary>
        /// Asynchronous after event that occurs after a new item has been added to its containing object.
        /// </summary>
        /// <param name="properties">
        /// A Microsoft.SharePoint.SPItemEventProperties object that represents properties of the event handler.
        /// </param>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            using (SPWeb web = properties.OpenWeb())
            {
                web.AllowUnsafeUpdates = true;

                string filetype = string.Empty;
                SPListItem item = properties.ListItem;
                SPFile file = item.File;
                SPFolder folder = file.ParentFolder;
                filetype = folder.Url.Substring(folder.Url.IndexOf('/') + 1);

                item["文档类型"] = filetype;

                item.Update();
            }
        }
    }
}
